require("../../utils/ut.js");

var t = null, a = !1, e = {
    x: 0,
    y: 0
}, o = {
    x1: 0,
    y1: 0,
    x2: 0,
    y2: 0
}, s = {
    x: 0,
    y: 0
}, i = getApp(), n = "https://txjdxx.cn/img/", r = null;

Page({
    imageFormat: 640,
    ctx: wx.createCanvasContext("canvas_test"),
    data: {
        text: "",
        msg: "",
        src: "https://wq.qyyh.xyz/xcx/xcxtz/wzry/timg.jpg",
        posters: "https://wq.qyyh.xyz/xcx/xcxtz/wzry/share.jpg",
        canvas_posters_path: "",
        width: 0,
        height: 0,
        left: 0,
        top: 0,
        scale: 1,
        rotate: 0,
        info: "",
        format: 1,
        showTemp: 0,
        defaultFrame: [],
        orgFrame: "",
        showOrg: !1,
        isOrg: !1,
        tab: [],
        outLeft: 0,
        outTop: 0,
        proportion: 0,
        headBox: [ 0, 0 ],
        originX: 100,
        originY: 100,
        loadStatus: [],
        changeX: 0,
        changeY: 0,
        musicIconRotate: 0,
        musicStatus: !0,
        timer: "",
        audioCtx: "",
        shareStatus: !1,
        showHint: !1,
        showImage: {
            width: 360,
            height: 360,
            left: 0,
            top: 0,
            rotate: 0,
            scale: 1
        },
        adjust: !1,
        buttonLock: !0,
        model: !0,
        rotateThis: 0,
        frame: [],
        mobileModel: 0,
        tabPosition: 0,
        orgList: [],
        musicSrc: "https://wq.qyyh.xyz/xcx/xcxtz/wzry/zlyl.mp3",
        gift: [],
        getUserInfo: !1,
        showLayer: !0,
        savePosters: !0,
        assign: {
            active: {
                show: !1,
                animal: "hideActive"
            }
        }
    },
    onLoad: function(a) {
        wx.createInterstitialAd && ((r = wx.createInterstitialAd({
            adUnitId: "adunit-a2c2bdff627f59a1"
        })).onLoad(function() {}), r.onError(function(t) {}), r.onClose(function() {}));
        var e = this;
        wx.createRewardedVideoAd && ((t = wx.createRewardedVideoAd({
            adUnitId: "adunit-2028a81a7f41aed3"
        })).onLoad(function() {}), t.onError(function(t) {}), t.onClose(function(t) {
            if (t && t.isEnded) {
                var a = e;
                wx.getSetting({
                    success: function(t) {
                        console.log(t), null == t.authSetting["scope.writePhotosAlbum"] || t.authSetting["scope.writePhotosAlbum"] ? (a.setData({
                            showLayer: !0
                        }), 0 == a.data.isOrg ? a.savePhoto() : (wx.showLoading({
                            title: "正在保存头像"
                        }), a.saveImageToPhone(a.data.orgFrame))) : wx.openSetting();
                    }
                });
            }
        })), i.assign(this, {
            layer: {
                opacity: "opacity_5",
                show: "hide"
            }
        }), i.assign(this, {
            share: {
                show: "hide"
            }
        });
        var o = this;
        o.setData({
            format: 1
        }), o.setData({
            mobileModel: i.mobileModel
        }), wx.getStorage({
            key: "shareStatus",
            success: function(t) {
                var a = Date.parse(new Date());
                (a /= 1e3) - t.data < 86400 ? o.setData({
                    shareStatus: !0
                }) : o.setData({
                    shareStatus: !1
                });
            },
            fail: function() {}
        }), i.getFrameData().then(function(t) {
            "error" == t ? (wx.showToast({
                title: "网络连接中断"
            }), exit()) : (wx.getStorage({
                key: "frameConfig",
                success: function(t) {
                    var a = JSON.parse(t.data);
                    console.log(a.data), i.assign(o, {
                        ad: {
                            show: a.data.ad.open,
                            title: a.data.ad.title,
                            link: a.data.ad.link
                        }
                    }), setTimeout(function() {
                        i.assign(o, {
                            active: {
                                show: a.data.active.open,
                                animal: "showActive"
                            }
                        });
                    }, a.data.active.delay), i.assign(o, {
                        shareStatus: {
                            show: a.data.share.open
                        }
                    }), console.log(o.data.assign);
                    for (var e = a.data.frame, s = Object.keys(e).length, n = new Object(), r = 0; r < s; r++) n[r] = new Object(), 
                    n[r].type = e[r][0].type, n[r].tab = e[r][0].tab, n[r].id = r, n[r].select = 0 == r;
                    o.setData({
                        tab: n,
                        gift: a.data.gift,
                        savePosters: a.data.posters
                    }), o.getCacheData(0, !0);
                }
            }), wx.getUserInfo({
                withCredentials: !1,
                success: function(t) {
                    var a = t.userInfo.avatarUrl, e = a.length, s = a.lastIndexOf("/"), i = a.substring(s + 1, e), n = a.replace(i, "0");
                    o.setData({
                        src: n
                    });
                },
                fail: function(t) {
                    o.setData({
                        src: "https://wq.qyyh.xyz/xcx/xcxtz/wzry/timg.jpg"
                    });
                }
            }));
        });
        var s = wx.createSelectorQuery();
        s.select(".main").boundingClientRect(), s.exec(function(t) {
            o.data.proportion = 750 / t[0].width;
        }), this.audioCtx = i.audioCtx, o.counttime(o), i.isInit = !1;
    },
    onReachBottom: function() {},
    bindload: function(t) {
        var a = t.detail.width, e = t.detail.height, o = new Object();
        e > a ? (e = 640 * e / a, a = 640, o.width = 360, o.height = 360 * e / a) : e < a ? (a = 640 * a / e, 
        e = 640, o.height = 360, o.width = 360 * a / e) : (a = 640, e = 640, o.width = 360, 
        o.height = 360), o.rotate = 0, o.scale = 1, o.left = (360 - o.width) / 2, o.top = (360 - o.height) / 2, 
        this.setData({
            width: a,
            height: e,
            left: 16 * o.left / 9,
            top: 16 * o.top / 9,
            rotate: 0,
            scale: 1,
            showImage: o
        }), wx.hideLoading(), i.assign(this, {
            layer: {
                opacity: "opacity_5",
                show: "hide"
            }
        });
    },
    touchstart: function(t) {
        var s = this;
        t.touches.length < 2 ? (a = !a, e.x = t.touches[0].pageX * s.data.proportion, e.y = t.touches[0].pageY * s.data.proportion) : (a = !1, 
        o.x1 = t.touches[0].pageX * s.data.proportion, o.y1 = t.touches[0].pageY * s.data.proportion, 
        o.x2 = t.touches[1].pageX * s.data.proportion, o.y2 = t.touches[1].pageY * s.data.proportion);
    },
    touchmove: function(t) {
        var s = this;
        if (t.touches.length < 2 && a) {
            var i = t.touches[0].pageX * s.data.proportion - e.x, n = t.touches[0].pageY * s.data.proportion - e.y, r = s.data.left + i;
            r < -s.data.width * s.data.scale + 160 ? r = -s.data.width * s.data.scale + 160 : r > 480 && (r = 480);
            var c = s.data.top + n;
            c < -s.data.height * s.data.scale + 160 ? c = -s.data.height * s.data.scale + 160 : c > 480 && (c = 480), 
            s.data.changeX = r + s.data.width * s.data.scale / 2, s.data.changeY = c + s.data.height * s.data.scale / 2, 
            s.setData({
                msg: "单点移动",
                left: r,
                top: c
            }), e.x = t.touches[0].pageX * s.data.proportion, e.y = t.touches[0].pageY * s.data.proportion;
        } else if (t.touches.length > 1) {
            var h = JSON.parse(JSON.stringify(o));
            o.x1 = t.touches[0].pageX * s.data.proportion, o.y1 = t.touches[0].pageY * s.data.proportion, 
            o.x2 = t.touches[1].pageX * s.data.proportion, o.y2 = t.touches[1].pageY * s.data.proportion;
            var d = 180 * Math.atan((h.y1 - h.y2) / (h.x1 - h.x2)) / Math.PI, l = (Math.atan2(h.y1 - h.y2, h.x1 - h.x2), 
            Math.PI, 180 * Math.atan((o.y1 - o.y2) / (o.x1 - o.x2)) / Math.PI);
            if (Math.abs(d - l) > 1) ; else {
                var u = Math.sqrt(Math.pow(h.x1 - h.x2, 2) + Math.pow(h.y1 - h.y2, 2)), g = Math.sqrt(Math.pow(o.x1 - o.x2, 2) + Math.pow(o.y1 - o.y2, 2)) - u, w = s.data.scale + .005 * g * s.data.scale;
                w > 9.91 && g > 0 && (w = 10), w < .51 && g < 0 && (w = .5);
                var p = s.data.scale;
                s.data.scale = w, s.setData({
                    msg: "缩放",
                    scale: w
                }), w < 10 && w > .5 && (s.data.left = s.data.left - (w - p) * s.data.width / 2, 
                s.data.top = s.data.top - (w - p) * s.data.height / 2, s.setData({
                    left: s.data.left,
                    top: s.data.top
                }));
            }
        }
    },
    touchend: function(t) {
        a = !1;
    },
    selectImage: function() {
        var t = this;
        1 != t.data.isOrg && wx.chooseImage({
            count: 1,
            sizeType: [ "compressed" ],
            sourceType: [ "album", "camera" ],
            success: function(a) {
                t.checkImage(a);
            }
        });
    },
    showTemp: function() {
        this.getCacheData(), this.setData({
            showTemp: 1
        });
    },
    hideTemp: function() {
        this.setData({
            showTemp: 0
        });
    },
    clickFrame: function(t) {
        var a = this;
        if (console.log("点击相框"), t.target.dataset.imgsrc == this.data.defaultFrame.src) ; else {
            wx.hideLoading({}), wx.showLoading({
                title: "加载中"
            });
            var e = t.target.dataset.org, o = t.target.dataset.tab, s = a.data.orgList;
            null != s[o] ? a.setData({
                defaultFrame: {
                    id: 1,
                    src: t.target.dataset.imgsrc
                },
                orgFrame: s[o],
                showOrg: !1
            }) : wx.downloadFile({
                url: e,
                success: function(e) {
                    200 === e.statusCode && (s[o] = e.tempFilePath, a.setData({
                        defaultFrame: {
                            id: 1,
                            src: t.target.dataset.imgsrc
                        },
                        orgFrame: e.tempFilePath,
                        showOrg: !1,
                        orgList: s
                    }));
                }
            });
        }
    },
    Getwxtx: function() {
        var t = this, a = wx.getStorageSync("LoginSession");
        "" === a ? (console.log("等于空" + a), wx.getUserProfile({
            desc: "正在获取",
            success: function(a) {
                console.log("获取成功: ", a), wx.setStorageSync("LoginSession", a), t.setData({
                    src: a.userInfo.avatarUrl
                });
            },
            fail: function(t) {
                console.log("获取失败: ", t);
            }
        })) : (console.log("有数据"), this.setData({
            src: a.userInfo.avatarUrl
        }), console.log("获取成功: ", a));
    },
    nextStep: function() {
        wx.showModal({
            title: "提示",
            content: "是否观看广告保存图片？",
            showCancel: !0,
            cancelText: "否",
            confirmText: "是",
            success: function(a) {
                a.cancel ? console.log("您点击了取消") : a.confirm && (t && t.show().catch(function() {
                    t.load().then(function() {
                        return t.show();
                    }).catch(function(t) {
                        console.log("激励视频 广告显示失败");
                    });
                }), console.log("您点击了确定"));
            }
        });
    },
    savePhoto: function() {
        var t = this;
        if (1 == t.data.buttonLock) {
            t.data.buttonLock = !1, wx.showLoading({
                title: "正在保存头像"
            }), t.ctx.rect(0, 0, 640, 640), t.ctx.setFillStyle("white"), t.ctx.fill(), t.ctx.draw();
            var a = t.data.width * t.data.scale, e = t.data.height * t.data.scale, o = t.data.left + a / 2, s = t.data.top + e / 2, i = t.data.rotate;
            t.ctx.translate(o, s), t.ctx.rotate(i * Math.PI / 180), 0 != t.data.format ? wx.downloadFile({
                url: t.data.src,
                success: function(o) {
                    t.ctx.drawImage(o.tempFilePath, -a / 2, -e / 2, a, e), t.ctx.draw(!0, function() {
                        t.drawFrame();
                    });
                },
                fail: function(t) {
                    wx.showToast({
                        title: "获取图片失败",
                        icon: "error",
                        duration: 2e3
                    });
                }
            }) : (t.ctx.drawImage(t.data.src, -a / 2, -e / 2, a, e), t.ctx.draw(!0, function() {
                t.drawFrame();
            }));
        }
    },
    drawFrame: function() {
        console.log(1111);
        var t = this, a = t.data.width * t.data.scale, e = t.data.height * t.data.scale, o = t.data.left + a / 2, s = t.data.top + e / 2, i = t.data.rotate;
        wx.downloadFile({
            url: t.data.defaultFrame.src,
            success: function(a) {
                console.log(a), t.ctx.translate(0, 0), t.ctx.rotate(-i * Math.PI / 180), t.ctx.drawImage(a.tempFilePath, -o, -s, 640, 640), 
                t.ctx.draw(!0, function() {
                    t.saveimg();
                });
            },
            fail: function(a) {
                wx.showToast({
                    title: "获取图片失败",
                    icon: "error",
                    duration: 2e3
                }), t.data.buttonLock = !0, t.setData({
                    showLayer: !1
                });
            }
        });
    },
    onShow: function() {
        i.audioStatus && this.audioCtx.play(), r && r.show().catch(function(t) {
            console.error(t);
        });
    },
    onHide: function() {},
    saveimg: function() {
        var t = this;
        wx.canvasToTempFilePath({
            x: 0,
            y: 0,
            destWidth: 640,
            destHeight: 640,
            fileType: "jpg",
            canvasId: "canvas_test",
            success: function(a) {
                t.saveImageToPhone(a.tempFilePath), t.data.buttonLock = !0, i.assign(t, {
                    layer: {
                        show: "hide"
                    }
                });
            },
            error: function() {
                wx.showToast({
                    title: "生成头像失败"
                }), i.assign(t, {
                    layer: {
                        show: "hide"
                    }
                });
            }
        });
    },
    onShareAppMessage: function(t) {
        var a = this;
        return {
            title: "王者主播职业头像，帅爆你的朋友圈！",
            path: "/pages/gestures/index",
            success: function(t) {
                Date.parse(new Date()), a.setData({
                    showHint: !1,
                    shareStatus: !0
                });
            },
            fail: function(t) {},
            complete: function() {}
        };
    },
    getCacheData: function() {
        var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 0, a = arguments.length > 1 && void 0 !== arguments[1] && arguments[1], e = this;
        wx.getStorage({
            key: "frameConfig",
            success: function(o) {
                for (var s = JSON.parse(o.data).data.frame[t], i = "", n = "", r = "", c = "", h = "", d = Object.keys(s).length, l = 0; l < d; l++) {
                    c = s[l].type + "_" + (l - 1);
                    var u = e.replaceUrl(s[l].thumb);
                    0 == l ? (null != e.data.loadStatus[c] ? i = '[{"id":"' + l + '","src":"' + u.big + '","type":' + e.data.loadStatus[c] + ',"tab":"' + c + '","thumb":"' + u.thumb + '","original":"' + u.original + '"}' : (i = '[{"id":"' + l + '","src":"' + u.big + '","type":' + !1 + ',"tab":"' + c + '","thumb":"' + u.thumb + '","original":"' + u.original + '"}', 
                    e.data.loadStatus[c] = !1), n = '{"id":"' + l + '","src":"' + u.big + '"}', r = u.original, 
                    h = c) : null != e.data.loadStatus[c] ? i = i + ',{"id":"' + l + '","src":"' + u.big + '","type":' + e.data.loadStatus[c] + ',"tab":"' + c + '","thumb":"' + u.thumb + '","original":"' + u.original + '"}' : (i = i + ',{"id":"' + l + '","src":"' + u.big + '","type":' + !1 + ',"tab":"' + c + '","thumb":"' + u.thumb + '","original":"' + u.original + '"}', 
                    e.data.loadStatus[c] = !1);
                }
                if (i += "]", e.data.frame = JSON.parse(i), e.setData({
                    frame: JSON.parse(i),
                    loadStatus: e.data.loadStatus
                }), a) {
                    var g = e.data.orgList;
                    wx.downloadFile({
                        url: r,
                        success: function(t) {
                            200 === t.statusCode && (g[h] = t.tempFilePath, e.setData({
                                defaultFrame: JSON.parse(n),
                                orgFrame: t.tempFilePath,
                                showOrg: !1,
                                orgList: g
                            }));
                        }
                    });
                }
            },
            fail: function(t) {}
        });
    },
    selectType: function(t) {
        var a = this;
        a.getCacheData(t.target.dataset.value);
        for (var e = Object.keys(a.data.tab).length, o = 0; o < e; o++) o == t.target.dataset.value ? a.data.tab[o].select = !0 : a.data.tab[o].select = !1;
        a.setData({
            tab: a.data.tab
        });
    },
    getItemInfo: function(t) {
        var a = this, e = wx.createSelectorQuery();
        e.select(t).boundingClientRect(), e.exec(function(t) {
            a.data.outLeft = t[0].left / a.data.proportion, a.data.outTop = t[0].top / a.data.proportion;
        });
    },
    reset: function() {
        this.setData({
            scale: 1,
            rotate: 0
        });
    },
    imageLoad: function(t) {
        var a = this, e = t.target.dataset.tab, o = t.target.dataset.order;
        a.data.loadStatus[e] = !0;
        var s = a.data.frame[o].tab;
        a.data.frame[o].type = a.data.loadStatus[s], a.setData({
            frame: a.data.frame
        });
    },
    counttime: function(t) {
        var a = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1];
        a ? t.data.timer = setTimeout(function() {
            t.setData({
                musicIconRotate: (t.data.musicIconRotate + 2) % 360
            }), t.counttime(t, a);
        }, 50) : clearTimeout(t.data.timer);
    },
    changeMusic: function() {
        this.data.musicStatus ? (this.counttime(this, !1), this.data.musicStatus = !1, this.setData({
            musicStatus: !1
        }), i.audioStatus = !1, this.audioCtx.pause()) : (this.counttime(this, !0), this.data.musicStatus = !0, 
        this.setData({
            musicStatus: !0
        }), i.audioStatus = !0, this.audioCtx.play());
    },
    adjustImage: function() {
        1 != this.data.isOrg && this.setData({
            adjust: !0
        });
    },
    closeAdjust: function() {
        this.setData({
            adjust: !1,
            scale: this.data.showImage.scale,
            rotate: this.data.showImage.rotate,
            left: 16 * this.data.showImage.left / 9,
            top: 16 * this.data.showImage.top / 9
        });
    },
    resetAdjust: function() {
        this.setData({
            scale: this.data.showImage.scale,
            rotate: this.data.showImage.rotate,
            left: 16 * this.data.showImage.left / 9,
            top: 16 * this.data.showImage.top / 9
        });
    },
    saveStyle: function() {
        this.data.showImage.scale = this.data.scale, this.data.showImage.rotate = this.data.rotate, 
        this.data.showImage.top = 9 * this.data.top / 16, this.data.showImage.left = 9 * this.data.left / 16, 
        this.setData({
            showImage: this.data.showImage,
            adjust: !1
        });
    },
    finishLoad: function() {
        this.data.isOrg && this.setData({
            showOrg: !0
        }), wx.hideLoading();
    },
    replaceUrl: function(t) {
        var a = new RegExp("_thumb.jpg", "g"), e = t, o = new Array();
        return o.big = n + e.replace(a, ".png"), o.thumb = n + t, o.original = n + e.replace(a, "_org.jpg"), 
        o;
    },
    useOrg: function() {
        1 == this.data.isOrg ? (this.data.isOrg = !1, this.setData({
            isOrg: !1,
            showOrg: !1
        })) : (this.data.isOrg = !0, this.setData({
            isOrg: !0,
            showOrg: !0
        }));
    },
    showIcon: function(t) {
        t.detail.scrollLeft < 50 ? this.setData({
            tabPosition: 0
        }) : t.detail.scrollLeft + 10 > t.detail.scrollWidth - 750 / this.data.proportion ? this.setData({
            tabPosition: 1
        }) : this.setData({
            tabPosition: 2
        }), console.log(this.data.tabPosition);
    },
    jumpLink: function(t) {
        var a = i.globalData.login.data;
        null != a ? a.ongoing ? wx.navigateTo({
            url: "/page/cheer/index?user=" + a.unionid
        }) : wx.navigateTo({
            url: "/page/worldCup/index?user=" + a.unionid
        }) : wx.navigateTo({
            url: "/page/worldCup/index?user=" + !1
        });
    },
    saveImageToPhone: function(t) {
        var a = this;
        wx.saveImageToPhotosAlbum({
            filePath: t,
            success: function(e) {
                wx.showToast({
                    title: "保存图片成功"
                }), a.ctx.rect(0, 0, 640, 640), a.ctx.setFillStyle("white"), a.ctx.fill(), a.ctx.draw(), 
                a.download_posters(t);
            },
            fail: function(t) {
                console.log(t), "saveImageToPhotosAlbum:fail auth deny" === t.errMsg && (a.setData({
                    showLayer: !1
                }), a.data.buttonLock = !0), wx.showToast({
                    title: "图片保存失败",
                    icon: "none",
                    duration: 2e3,
                    complete: function() {
                        wx.hideLoading(), a.data.buttonLock = !0, a.setData({
                            showLayer: !1
                        });
                    }
                });
            }
        });
    },
    download_posters: function(t) {
        var a = this;
        a.data.savePosters ? wx.downloadFile({
            url: a.data.posters,
            success: function(e) {
                a.canvasPostors(t, e.tempFilePath);
            },
            fail: function(t) {
                wx.showToast({
                    title: "获取图片失败",
                    icon: "error",
                    duration: 2e3
                }), a.data.buttonLock = !0, a.setData({
                    showLayer: !1
                });
            }
        }) : a.showShare();
    },
    canvasPostors: function(t, a) {
        var e = this, o = wx.createCanvasContext("canvas_posters");
        o.drawImage(a, 0, 0, 750, 1334), o.draw(), o.drawImage(t, 75, 169, 320, 320), o.draw(!0, function(t) {
            e.savePorts();
        });
    },
    savePorts: function() {
        var t = this;
        wx.canvasToTempFilePath({
            x: 0,
            y: 0,
            destWidth: 750,
            destHeight: 1334,
            canvasId: "canvas_posters",
            fileType: "jpg",
            success: function(a) {
                t.data.canvas_posters_path = a.tempFilePath, wx.saveImageToPhotosAlbum({
                    filePath: t.data.canvas_posters_path,
                    success: function(t) {},
                    fail: function(a) {
                        "saveImageToPhotosAlbum:fail auth deny" === a.errMsg ? (wx.openSetting({
                            success: function(t) {
                                t.authSetting["scope.writePhotosAlbum"];
                            }
                        }), t.data.buttonLock = !0) : wx.showToast({
                            title: "图片保存失败",
                            icon: "none",
                            duration: 2e3,
                            complete: function() {
                                wx.hideLoading(), t.data.buttonLock = !0;
                            }
                        });
                    }
                });
            },
            fail: function() {
                t.setData({
                    showLayer: !1
                });
            }
        });
    },
    getUserInfoFun: function(t) {
        if (this.setData({
            getUserInfo: !1
        }), null == t.detail.userInfo) ; else {
            i.getUser(t.detail);
            var a = t.detail.userInfo.avatarUrl, e = a.length, o = a.lastIndexOf("/"), s = a.substring(o + 1, e), n = a.replace(s, "0");
            this.setData({
                src: n
            }), i.assign(this, {
                layer: {
                    opacity: "opacity_5",
                    show: "show"
                }
            }), wx.showLoading({
                title: "正在加载"
            });
        }
    },
    closeShare: function() {
        i.assign(this, {
            layer: {
                show: "hide"
            },
            share: {
                show: "hide"
            }
        });
    },
    showShare: function() {
        var t = this;
        wx.hideLoading(), t.data.assign.shareStatus.show ? i.assign(t, {
            layer: {
                show: "show",
                opacity: "opacity_8"
            },
            share: {
                show: "show"
            }
        }) : wx.showToast({
            title: "图片保存成功",
            icon: "success",
            duration: 2e3,
            complete: function() {
                t.data.buttonLock = !0;
            }
        });
    },
    jumpAd: function() {
        wx.navigateTo({
            url: "/page/web/index?link=" + this.data.assign.ad.link
        });
    },
    close_active: function() {
        i.assign(this, {
            active: {
                show: !0,
                animal: "hideActive"
            }
        });
    },
    touchstart_cab: function(t) {
        t.touches.length < 2 && (s.x = t.touches[0].pageX * this.data.proportion, s.y = t.touches[0].pageY * this.data.proportion);
    },
    touchmove_cab: function(t) {
        var a = this;
        if (t.touches.length < 2) {
            var e = s.x - t.touches[0].pageX * a.data.proportion, o = s.y - t.touches[0].pageY * a.data.proportion;
            e > 720 ? e = 720 : e < -720 && (e = -720);
            var n = (a.data.rotate + e / 4) % 360;
            a.setData({
                rotate: n
            }), new RegExp(/iPhone/).test(i.globalData.mobileModel) && wx.vibrateShort({
                success: function() {}
            }), s.x = t.touches[0].pageX * a.data.proportion, s.y = t.touches[0].pageY * a.data.proportion, 
            console.log(e, o);
        }
    },
    touchend_cab: function(t) {
        s.x = 0, s.y = 0;
    },
    checkImage: function(t) {
        var a = this;
        wx.showLoading({
            title: "正在加载...",
            mask: !0
        }), wx.uploadFile({
            url: "https://ssl.xiaokatouxiang.cn/open/Home/Index/checkImage",
            filePath: t.tempFilePaths[0],
            name: "file",
            formData: {
                user: "test"
            },
            success: function(e) {
                JSON.parse(e.data).result ? a.setImage(t) : (wx.hideLoading(), wx.showToast({
                    icon: "none",
                    title: "图片含有违规信息",
                    mask: !0
                }));
            }
        });
    },
    setImage: function(t) {
        var a = this;
        wx.hideLoading();
        var e = t.tempFilePaths;
        wx.getImageInfo({
            src: t.tempFilePaths[0],
            success: function(t) {
                var o = t.width, s = t.height;
                s > o ? (s = 640 * s / o, o = 640, a.data.showImage.width = 360, a.data.showImage.height = 360 * s / o) : s < o ? (o = 640 * o / s, 
                s = 640, a.data.showImage.height = 360, a.data.showImage.width = 360 * o / s) : (o = 640, 
                s = 640, a.data.showImage.width = 360, a.data.showImage.height = 360), a.data.showImage.rotate = 0, 
                a.data.showImage.scale = 1, a.data.left = (360 - a.data.showImage.width) / 2, a.data.top = (360 - a.data.showImage.height) / 2, 
                a.setData({
                    src: e[0],
                    format: 0,
                    width: o,
                    height: s,
                    left: (640 - o) / 2,
                    top: (640 - s) / 2,
                    rotate: 0,
                    scale: 1,
                    showImage: a.data.showImage
                }), a.data.musicStatus;
            }
        });
    }
});